// Before using this class,
// You should include
// "windows.h"
// "Inklude/CString.h"


#ifndef __INKLUDE_C_SHARED_MEMORY_H__
#define __INKLUDE_C_SHARED_MEMORY_H__

#ifndef __INKLUDE_C_STRING_H__
#include <Inklude/ikCString.h>
#endif

#ifndef _WINDOWS_
#include <windows.h>
#endif

#include <Inklude/Inklude.h>

namespace Inklude
{

class INKLUDE_CLASS_EXPORT ikCSharedMemory
{
public:
    ikCSharedMemory();
    ~ikCSharedMemory();
    bool CreateMemory(Inklude::ikCString& SharedMemoryIdentifier, unsigned int MemorySize = 4096);
    bool ReadMemory (char* Buffer, unsigned int ReadSize,  unsigned int Offset = 0);
    bool WriteMemory(char* Buffer, unsigned int WriteSize, unsigned int Offset = 0);
    bool IsNewlyWritten();
protected:

private:
    HANDLE m_hMemory;
    unsigned int m_bufSize;
    char* m_pBuffer;
    HANDLE m_hMutex;
    bool   m_bIsRead;
};

} // namespace Inklude

#endif // __INKLUDE_C_SHARED_MEMORY_H__
